SELECT a.RAGF_ID,trunc(a.VER_DTINI) ver_dtini,trunc(a.VER_DTFINE) ver_dtfine,a.MPAG_DES,a.ABICAB_CAB,a.RFRP_PAESE,a.RFRP_CIN,a.RFRP_CHKDGT,a.ABICAB_ABI,a.ABICAB_DES,a.RFRP_CC,
       b.CON_ANNO,b.CON_ID,trunc(b.VER_DTINI) ver_dtini_con,trunc(b.VER_DTFINE) ver_dtfine_con,b.TCON_DES,b.SER_des,b.sog_id,b.SOG_RAGSOC,b.tsog_des,
       trunc(b.CON_DTINIGES) dt_iniges,trunc(b.CON_DTULTCALRIP) CON_DTULTCALRIP,b.TATTI_DES,trunc(b.CON_DTINIINTDEPCAU) CON_DTINIINTDEPCAU
FROM V_RAGFATREGPAG A, 
     V_CONTRATTO B
WHERE A.RFRP_FLSTARICDOM = 0
and a.az_id ='01'
and b.az_id ='01'
  AND A.ABICAB_DES IS NULL
  AND A.RFRP_FLTIPOPAG = 'R'
  AND A.VER_DTFINE = TO_DATE('31129999','DDMMYYYY')
  AND A.STA_IDSYS = 2
  AND A.RAGF_ID = B.RAGF_ID
  AND B.STA_IDSYS= 2